<tagLib name="html" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <HEAD>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <TITLE>菜单挑选</TITLE>
        <load type="css" href ="../Public/css/style.css" />
        <load  type="js" file="Js.Util.JTree" /> 
        <SCRIPT LANGUAGE="JavaScript">
            <!--
            function ok(){
                var isMSIE= (navigator.appName == "Microsoft Internet Explorer");  
                var result = new Array();
                result[0]	= new Array();
                result[0][0]	=	document.getElementById('Name').value;
                result[0][1]	=	document.getElementById('Id').value;
                result[0][2]	=	document.getElementById('Level').value;
                if (isMSIE){  
                    returnValue=result;
                }else{
                    window.opener.document.form1.columnName.value	=	result[0][0];
                    window.opener.document.form1.column_id.value	=	result[0][1];	
                }
                top.close(); 
            }

            //-->
        </SCRIPT>
        <base target="_self" />
    </HEAD>
    <BODY style="margin:0;overflow:hidden">
        <FORM METHOD="POST" style="margin:0" name = "form1" ACTION="" onsubmit="return navTabSearch(this)" >
            <div align="center">
                <TABLE class="order" cellpadding=0 style="margin:0" cellspacing=0 width="100%">
                    <tr><td height="5" colspan="2" class="topTd" ></td></tr>
                    <TR>
                        <Th colspan=2 align="center"><div class="fLeft"><input name="nodeCaption" id="nodeCaption" type="text" style="width:165px"></div>
                            <html:imageBtn name="search" value="查询" click="findNode(myTree.treeNodes)" style="impBtn hMargin fLeft " /></Th>
                    </TR>
                    <TR >
                        <TD width="75%" >
                            <input TYPE="hidden" id="Id" ><input TYPE="hidden" id="Name" ><input TYPE="hidden" id="Level" >
                                        <div id="showTree" ></div>
                                        </TD>
                                        </TR>
                                        <TR>
                                            <TD colspan=2 align="center">
                                                <input TYPE="button" class="button shadow" value="确 定" onclick="ok()" >
                                                    <input TYPE="button" class="button shadow" value="取 消" onclick="window.close()" >
                                                        </TD>
                                                        </TR>
                                                        <tr><td height="5" colspan="2" class="topTd" ></td></tr>
                                                        </TABLE>
                                                        </div>
                                                        </FORM>
                                                        <script language="javascript" type="text/javascript">
                                                            <!--
                                                            function setValueById(pObjID,pValue){
                                                                var obj=document.getElementById(pObjID);
                                                                try{
                                                                    obj.value=pValue;
                                                                }catch(e){
                                                                    alert("控件："+pObjID+"　不存在，或没有value属性")
                                                                }
                                                            }
	
                                                            function $(pID){
                                                                return document.getElementById(pID);
                                                            }
	
                                                            function getNodeAtt(pNode,pAtt){
                                                                try{
                                                                    return pNode.attributes.getNamedItem(pAtt).nodeValue;
                                                                }catch(e){
                                                                    //alert("前台调试错误：\n"+e.message+"\n当前节点不存在: "+pAtt+"这个属性");
                                                                }
                                                            }
                                                            parm	=	location.href.replace('http://'+location.hostname+'__ACTION__','');
                                                            var myTree=new JTree("showTree","__URL__/tree/title/{:urlencode('选择菜单')}/"+parm,false);
                                                            myTree.setPicPath("__ROOT__/Public/Images/JTreePic/")
                                                            myTree.onclick=function(){
                                                                if(getNodeAtt(myTree.selectNode,"id")==undefined){
                                                                    if (myTree.EXPANDALL == false)
                                                                    {
                                                                        myTree.expand(true);
                                                                    }else {
                                                                        myTree.expand(false);
                                                                    }
			
                                                                }else {
                                                                    setValueById("Id",getNodeAtt(myTree.selectNode,"id"));
                                                                    setValueById("Name",getNodeAtt(myTree.selectNode,"caption"));
                                                                    setValueById("Level",getNodeAtt(myTree.selectNode,"level"));
                                                                }
                                                            }
                                                            myTree.ondblclick=function(){
                                                                if(getNodeAtt(myTree.selectNode,"id")!=undefined){
                                                                    setValueById("Id",getNodeAtt(myTree.selectNode,"id"));
                                                                    setValueById("Name",getNodeAtt(myTree.selectNode,"caption"));
                                                                    setValueById("Level",getNodeAtt(myTree.selectNode,"level"));
                                                                    ok();
                                                                }
                                                            }
                                                            myTree.CAPTIONATT="caption";
                                                            myTree.create();

                                                            function vControl(pChoice,pParm){
                                                                switch(pChoice){
                                                                    case "REPLACE":
                                                                        var pattern=/\([0-9]+\)$/;
                                                                        return pParm.replace(pattern,"");
                                                                        break;
                                                                    case "FINDNODE":
                                                                        var obj;
                                                                        for(var i=0;obj=pParm[i];i++){
                                                                            alert(obj.caption);
                                                                            if(obj.caption==$("nodeCaption").value)
                                                                                obj.click();
                                                                        }
                                                                        break;
                                                                }
                                                            }

                                                            function findNode(pTree){
                                                                var obj;
                                                                for(var i=0;obj=pTree[i];i++){
                                                                    str = $("nodeCaption").value;
                                                                    if(obj.caption.indexOf(str)!='-1'){
                                                                        obj.click();
                                                                        //obj.parentTreeNode.expand(true)
                                                                        myTree.clickItem.parentTreeNode.expand(true);
                                                                        return true;
                                                                    }
                                                                    findNode(obj.treeNodes)
                                                                }
                                                            }

                                                            -->
                                                        </script>
                                                        </html>